package cn.enilu.guns.bean.entity.door;


import cn.enilu.guns.bean.entity.system.User;
import cn.enilu.guns.utils.DateUtil;
import cn.enilu.guns.utils.StringUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import cn.enilu.guns.bean.entity.BaseEntity;
import org.apache.commons.lang3.time.DateUtils;
import org.hibernate.annotations.Table;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;
import java.util.Set;

@Entity(name="T_USER_CARD")
@Table(appliesTo = "t_user_card",comment = "人卡关系")
@Data
@EntityListeners(AuditingEntityListener.class)
public class UserCard extends BaseEntity {

	/**
	 * 
	 */
	@Column(columnDefinition = " INT(10) COMMENT ''")
	private Integer version;

	/**
	 * 用户id
	 */
//	@Column(columnDefinition = " BIGINT(19) COMMENT '用户id'")
//	private Long userId;

	/**
	 * 卡id
	 */
	@Column(columnDefinition = " BIGINT(19) COMMENT '卡id'")
	private Long cardId;
	/*
	是否解綁  0 否 1 是
	 */
	@Column(columnDefinition = " INT(10) COMMENT '是否解綁  0 否 1 是'")
	private Integer isUnbinding;
	/**
	 * 卡号
	 */
	@Column(columnDefinition = " VARCHAR(255) COMMENT '卡号'")
	private String cardNo;
	/*
	卡狀態
	 */
	@Column(columnDefinition = " INT(10) COMMENT '卡狀態'")
	private String status;
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name="user_id",referencedColumnName = "id",columnDefinition = "BIGINT(19) COMMENT '用户id'")
	private User userInfo;

	@Column(columnDefinition="DATETIME COMMENT '開始時間'")
	private Date startTime;

	@Column(columnDefinition="DATETIME COMMENT '開始時間'")
	private Date endTime;


	@Override
	public String toString() {
		return  "CardNo=" + cardNo + "\t" +
				"Pin=" + userInfo.getId() + "\t"+
				"Password=0\t"+
				"Group=0\t"+
				"StartTime=0\t"+
				"EndTime=0\t"+
				"SuperAuthorize=0";
	}
}
